<?php
	class MailManager
	{
		/* Attributs */
		public static $_listeMails = array(
// 			array('nom du fichier sans extension', 	'Intietulé')
			array('rappel_etudiant_adc',			'Rappel Etudiant ADC'),
			array('rappel_etudiant_ficheADC',		'Rappel Etudiant Fiche ADC'),
			array('inscription_auto_etudiant', 		'Inscription Auto Etudiant'),
			array('rappel_enseignant_adc', 			'Rappel Enseignant ADC'),
			array('rappel_enseignant_fiche_bilan', 	'Rappel Enseignant Fiche Blian'),
			array('proposition_adc', 				'Proposition ADC'),
			array('adc_incomplete', 				'ADC imcomplete'),
		);
		private $_contenu;
		private $_fileName;
		private $_objet;

		public function __construc()
		{
			$this->_fileName = "aucun";
			$this->_contenu = null;
		}

		public function load()
		{
			if(file_exists(CHEMIN_MAILS.$this->_fileName.'.html'))
			{
				$handle = fopen(CHEMIN_MAILS.$this->_fileName.'.html', 'r');
				$this->_objet = fgets($handle);
				$this->_contenu = fread($handle, filesize(CHEMIN_MAILS.$this->_fileName.'.html'));
				fclose($handle);

				return true;
			}
			else
				return false;
		}

		public function save()
		{
			if(!is_null($this->_contenu))
			{
				$handle = fopen(CHEMIN_MAILS.$this->_fileName.'.html', 'w');
				fputs($handle, $this->_objet."\n".$this->_contenu);
				fclose($handle);

				return true;
			}
			else
				return false;
		}

		public function get_contenu()
		{
			return htmlspecialchars_decode($this->_contenu);
		}

		public function set_contenu($c)
		{
			if (get_magic_quotes_gpc())
				$value = htmlspecialchars(stripslashes((string)$c));
			else
				$this->_contenu = htmlspecialchars($c);
		}

		public function get_fileName()
		{
			return $this->_fileName;
		}

		public function set_fileName($name)
		{
			$this->_fileName = $name;
		}

		public function get_objet()
		{
			return htmlspecialchars_decode($this->_objet);
		}

		public function set_objet($o)
		{
			if (get_magic_quotes_gpc())
				$value = htmlspecialchars(stripslashes((string)$o));
			else
				$this->_objet = htmlspecialchars($o);
		}
	}
?>
